<template>
  <div>
    <h1>App..</h1>
    <p>{{ count }}</p>
    <Child ref="child" />
  </div>
</template>

<script>
import Child from "./Child.vue";

export default {
  name: "App",
  data() {
    return {
      count: 0,
      obj: {},
    };
  },
  mounted() {
    // console.log(this.$refs);
    this.$refs.child.$on("update", this.update);
    this.$set(this.obj, "name", "laowang");
  },
  beforeDestroy() {
    this.$refs.child.$off("update", this.update);
  },
  methods: {
    update(...args) {
      this.count++;
      console.log(args);
    },
  },
  components: {
    Child,
  },
};
</script>

<style>
</style>